.TH std::array::fill 3 "2024.06.10" "http://cppreference.com" "C++ Standard Libary"
.SH NAME
std::array::fill \- std::array::fill

.SH Synopsis
   void fill( const T& value );  \fI(since C++11)\fP
                                 (constexpr since C++20)

   Assigns the value to all elements in the container.

.SH Parameters

   value - the value to assign to the elements

.SH Return value

   \fI(none)\fP

.SH Complexity

   Linear in the size of the container.

.SH Example


// Run this code

 #include <array>
 #include <cstddef>
 #include <iostream>

 int main()
 {
     constexpr std::size_t xy = 4;

     using Cell = std::array<unsigned char, 8>;

     std::array<Cell, xy * xy> board;

     board.fill({0xE2, 0x96, 0x84, 0xE2, 0x96, 0x80, 0, 0}); // "▄▀";

     for (std::size_t count{}; Cell c : board)
         std::cout << c.data() << ((++count % xy) ? "" : "\\n");
 }

.SH Possible output:

 ▄▀▄▀▄▀▄▀
 ▄▀▄▀▄▀▄▀
 ▄▀▄▀▄▀▄▀
 ▄▀▄▀▄▀▄▀

.SH See also

   fill         copy-assigns the given value to every element in a range
                \fI(function template)\fP
   fill_n       copy-assigns the given value to N elements in a range
                \fI(function template)\fP
   ranges::fill assigns a range of elements a certain value
   (C++20)      (niebloid)
